#ifndef GAME_OBJECT_H
#define GAME_OBJECT_H

#include <d3d9.h>
#include <D3dx9math.h>
#include <time.h>
#include <string>
#include <vector>
//#include "Model.h"
#include "Texture.h"
#include "vec3.h"

#pragma comment (lib, "winmm.lib")

struct CUSTOMVERTEX {FLOAT X, Y, Z; D3DVECTOR NORMAL;}; // Added normals for lighting
#define CUSTOMFVF (D3DFVF_XYZ | D3DFVF_NORMAL) // and here

class GameObject
{
public:
	GameObject(const std::string& type, bool textured, bool model);
	GameObject(LPD3DXMESH mesh);
	GameObject();
	~GameObject();
	bool Load(LPCWSTR filename);
	//void Init();
	void Transform();
	virtual void Render();
	void Update(float dt);
	void SetModel(LPCWSTR filename);
	//Model* GetModel();
	void Clean();

	CUSTOMVERTEX GetVertices(std::string& type);
	std::string &GetType();
	D3DXMATRIX GetTransform();
	D3DXMATRIX GetWorldMatrix();

	//Get	
	D3DXVECTOR3 GetPos();
	float GetPosX();
	float GetPosY();
	float GetPosZ();

	D3DXVECTOR3 GetVel();
	float GetVelX();
	float GetVelY();
	float GetVelZ();

	D3DXVECTOR3 GetAcc();
	float GetAccX();
	float GetAccY();
	float GetAccZ();

	D3DXVECTOR3 GetScale();
	float GetScaleX();
	float GetScaleY();
	float GetScaleZ();

	D3DXVECTOR3 GetRot();
	float GetRotX();
	float GetRotY();
	float GetRotZ();

	D3DXVECTOR3 GetOldPos();

	//Set
	void SetTexture(LPCWSTR s);

	void SetPos(D3DXVECTOR3 v);
	void SetPosX(float f);
	void SetPosY(float f);
	void SetPosZ(float f);

	void SetVel(D3DXVECTOR3 v);
	void SetVelX(float f);
	void SetVelY(float f);
	void SetVelZ(float f);

	void SetAcc(D3DXVECTOR3 v);
	void SetAccX(float f);
	void SetAccY(float f);
	void SetAccZ(float f);

	void SetScale(D3DXVECTOR3 v);
	void SetScaleX(float f);
	void SetScaleY(float f);
	void SetScaleZ(float f);

	void SetRot(D3DXVECTOR3 v);
	void SetRotX(float f);
	void SetRotY(float f);
	void SetRotZ(float f);

	void  SetOldPos(D3DXVECTOR3 v);

	bool GetDraw(){return m_bDraw;}
	void SetDraw(bool b){m_bDraw=b;}
	
protected:
	int m_NumSubsets;
	bool m_bDraw;
	D3DXVECTOR3 m_vPos;
	D3DXVECTOR3 m_vAcc;
	D3DXVECTOR3 m_vVel;
	D3DXVECTOR3 m_vRot;
	D3DXVECTOR3 m_vOldPos;
	D3DXVECTOR3 m_vScale;

	//Model* m_pModel;
	Texture* m_pTexture;
	std::string m_Type;

	LPD3DXMESH m_pMesh;

	D3DXMATRIX m_matTranslate; // the translation matrix
	D3DXMATRIX m_matScaling; // the scale matrix
	D3DXMATRIX m_matRotationX; // the rotation matrix x
	D3DXMATRIX m_matRotationY;
	D3DXMATRIX m_matRotationZ;
	D3DXMATRIX m_matWorld;

	D3DXVECTOR3 vLightDir;

	bool m_bTextured;
	bool m_bModel;
};
#endif